package com.zq.im.room.database;

import android.content.Context;

import com.zq.im.room.dao.MessageDao;
import com.zq.im.room.dao.UserDao;
import com.zq.im.room.entity.Message;
import com.zq.im.room.entity.User;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * Created by 张强 869518570@qq.com on 2020/9/22
 */
@Database(entities = {Message.class, User.class}, version = 1,exportSchema = false)
public abstract class MyDataBase extends RoomDatabase {

    private static volatile MyDataBase myDataBase;

    public static MyDataBase getInstance(Context context) {
        if (myDataBase == null) {
            synchronized (MyDataBase.class) {
                if (myDataBase == null) {
                    myDataBase = Room.databaseBuilder(context.getApplicationContext(),
                            MyDataBase.class, "IM.db").build();
                }
            }
        }
        return myDataBase;
    }

    public abstract MessageDao getMessageDao();

    public abstract UserDao getUserDao();



}
